<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ja v2.5</title>
    <style>
        .btn_phone { margin-top: 5px; }
    </style>
</head>
<body>
<div id="LoginBefore">
    <div>
        <h3>手机号登录</h3>
        <input type="text" class="input_phone" placeholder="请输入手机号"><br/>
        <input type="text" class="input_phone_code" placeholder="请输入验证码" style="width:80px">
        <button class="btn_phone_code">发送验证码</button><br/>
        <button class="btn_phone">手机号登录</button>
    </div>
    <div>
        <h3>平台登录</h3>
        <button class="btn_login_platform">平台登录</button>
    </div>
    <div>
        <h3>微信</h3>
        <button class="btn_wx_init">初始化</button>
        <button class="btn_wx_share">分享</button>
    </div>
</div>
<ul id="LoginAfter" hidden>
    <li class="username"></li>
    <li><button class="btn_http">请求测试</button></li>
    <li><a href="javascript:;" class="btn_logout">退出</a></li>
</ul>
</body>
<script src="/act/all/cdn/jquery/3.4.1/jquery.min.js"></script>
<script src="./join-activity.min.js"></script>
<script>
    ja.config({
        app: 'xtl',
        activity: 'fashion',
        version: '20200310',
        platform: 'changyou',

        // app: 'xtl',
        // activity: 'travelh5',
        // version: '20200330',
        // platform: 'changyou',

        type: 1,        // 接口请求方式不同
        loginType: 1,

        isWxLogin: true,
        isUserInit: true,
        isWxInit: true,
        wxShare: {
            title: '你的好友发来一封江湖秘闻', // 标题
            desc: '《新天龙八部》十月重磅更新，想要提前获得消息并领取xxxx, xxxx等江湖赠礼吗？快来参与活动吧！', // 介绍
            link: location.origin + "/xtl/guoqing/20190819/m/jhmw_share.shtml", // 访问路径，必须绝对路径
            imgUrl: 'http://singerimg.kugou.com/uploadpic/softhead/240/20160815/20160815163511387.jpg', // 图标路径，必须绝对路径
            hideMenuList: [
                'menuItem:share:timeline'
            ],
            success: function () {}
        },
        ready: function(glob) {
            console.log(glob);
            console.log({
                // 账号用户是否登录
                isLogin: glob.code === 1 && glob.userInfo.openType === 2,
                // 用户标识
                guid: glob.userInfo && glob.userInfo.guid
                //
            });
            glob.isLogin = glob.code === 1 && glob.userInfo.openType === 2;
            console.log(glob.isLogin);
            glob.code === 1 ? loginAfter() : loginBefore();
        }
    });

    function loginBefore() {
        $('#LoginBefore').show();
        $('#LoginAfter').hide();
    }
    function loginAfter() {
        $('#LoginBefore').hide();
        $('#LoginAfter').show();
        $('.username').text(ja.glob.userInfo.openid)
    }
    $('.btn_phone_code').click(function() {
        ja.user.getCode();
    });
    $('.btn_phone').click(function () {
        ja.user.loginPhone()
    });
    $('.btn_login_platform').click(function() {
        ja.login({
            from: 'bind',   // 固定值，隐藏“畅游移动”
            type: 'djuser'  // cyouuser | djuser | cyuser
        });
    });
    $('.btn_logout').click(function() {
        ja.logout();
    });

    // url 传参 取参
    var path = 'index';
    console.log(location.origin + "/xtl/competition/20191115/m/" + path + '.shtml' + ja.utils.setUrlParams({id: 1, name: '白木幽幽'}));
    console.log(ja.utils.getUrlParams());

    // 请求测试
    $('.btn_http').click(function() {
        ja.get('/changyou/tlgl/backtogether/addlottimes', function (res) {
           console.log(res);
        })
    })
</script>
</html>